/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entity;

import java.io.Serializable;
import java.sql.Date;
import java.sql.Timestamp;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToOne;

/**
 *
 * @author Ee Ting
 */
@Entity
public class MPSDailyRecord implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long mpsDailyId;
    
    private Date mpsDate;
    @OneToOne(cascade = {CascadeType.PERSIST})
    private ProdRecordMPS mpsMonthly;
    @OneToOne(cascade = {CascadeType.PERSIST})
    private ProdRecordMPS mpsDaily;  
    private int workingDaysMonthly;
    @OneToOne(cascade = {CascadeType.PERSIST})
    private SystemUser createdBy;
    private Timestamp createdDate;
    
    @OneToOne(cascade={CascadeType.PERSIST})
    private SOPRecord sopr;  
    
    
    public void create(java.util.Date mDate, ProdRecordMPS mMonth, ProdRecordMPS mDaily, int wDays, SystemUser user)
    {
        this.setMpsDate(new Date(mDate.getTime()));
        this.setMpsMonthly(mMonth);
        this.setMpsDaily(mDaily);
        this.setWorkingDaysMonthly(wDays);
        this.setCreatedBy(user);
        java.util.Date tmp = new java.util.Date();
        this.setCreatedDate(new Timestamp(tmp.getTime()));
    }

    public SOPRecord getSopr() {
        return sopr;
    }

    public void setSopr(SOPRecord sopr) {
        this.sopr = sopr;
    }

    
    public SystemUser getCreatedBy() {
        return createdBy;
    }

    public void setCreatedBy(SystemUser createdBy) {
        this.createdBy = createdBy;
    }

    public Timestamp getCreatedDate() {
        return createdDate;
    }

    public void setCreatedDate(Timestamp createdDate) {
        this.createdDate = createdDate;
    }

    public ProdRecordMPS getMpsDaily() {
        return mpsDaily;
    }

    public void setMpsDaily(ProdRecordMPS mpsDaily) {
        this.mpsDaily = mpsDaily;
    }

    public Date getMpsDate() {
        return mpsDate;
    }

    public void setMpsDate(Date mpsDate) {
        this.mpsDate = mpsDate;
    }

    public ProdRecordMPS getMpsMonthly() {
        return mpsMonthly;
    }

    public void setMpsMonthly(ProdRecordMPS mpsMonthly) {
        this.mpsMonthly = mpsMonthly;
    }

    public int getWorkingDaysMonthly() {
        return workingDaysMonthly;
    }

    public void setWorkingDaysMonthly(int workingDaysMonthly) {
        this.workingDaysMonthly = workingDaysMonthly;
    }
    

    public Long getMpsDailyId() {
        return mpsDailyId;
    }

    public void setMpsDailyId(Long id) {
        this.mpsDailyId = id;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (mpsDailyId != null ? mpsDailyId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof MPSDailyRecord)) {
            return false;
        }
        MPSDailyRecord other = (MPSDailyRecord) object;
        if ((this.mpsDailyId == null && other.mpsDailyId != null) || (this.mpsDailyId != null && !this.mpsDailyId.equals(other.mpsDailyId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entity.MPSDailyRecord[ id=" + mpsDailyId + " ]";
    }
    
}
